package com.string.practice;

import java.util.Scanner;

public class Roma {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s="";
        boolean flag = true;
        while (flag) {
            System.out.println("请输入字符串:");
            s = sc.next();
            if (s.length() <= 9) {
                for (int i = 0; i < s.length(); i++) {
                    if (s.charAt(i) < 48 || s.charAt(i) > 57) {
                        System.out.println("输入错误，请重新输入！");
                        break;
                    }
                    flag = false;
                }
            } else System.out.println("输入错误，请重新输入！");
        }

//        System.out.println("成功输入");
        char[] roma={' ','Ⅰ','Ⅱ','Ⅲ','Ⅳ','Ⅴ','Ⅵ','Ⅶ','Ⅷ','Ⅸ'};
        String result="";
        for (int i = 0; i < s.length(); i++) {
            result=result+roma[s.charAt(i)-48];//错误点 s.charAt(i)为字符类型 需要int
        }
        System.out.println(result);
    }
}
